<?php
declare (strict_types=1);

namespace app\common\controller;

class ServerResponse
{
    //构造函数
    public function __construct()
    {
//        跨域
//        header("Access-Control-Allow-Origin:*");
//        header("Access-Control-Allow-Methods:GET, POST, OPTIONS, DELETE");
//        header("Access-Control-Allow-Headers:DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type, Accept-Language, Origin, Accept-Encoding");

    }

    /***
     * 统一返回json格式
     * @param int $code 状态码
     * @param string $info 返回消息
     * @param array $data 返回数据
     * @return false|string
     */
    public static function jsonData($code = 1, $info = '', $data = [])
    {
        return json_encode(['code' => $code, 'info' => $info, 'data' => $data]);
    }
}